/*
 * Systick.h
 *
 *  Created on: 2012-3-31
 *      Author: Administrator
 */

#ifndef SYSTICK_H_
#define SYSTICK_H_


typedef struct timer
{
    INT32U State;
    INT32U Count;
    INT32U endtime;
    INT8U  name[32];
}Timer,*pTimer;

//extern Err DelTimer(pTimer t);
//extern pTimer AddTimer(INT32U endtime);

extern pTimer AddTimer(INT32U endtime,const INT8U *name);
// extern Err DelTimer(pTimer t);
extern void Sys_Delay(INT32U ms);
extern void DelayByLoop(INT32S n);
extern INT32U IsOver(pTimer t);
// extern Err IncreaseEndTime(pTimer pt, INT32U val);
// extern Err TimerClrCount(pTimer pt);
// extern Err TimerResume(pTimer pt);
// extern Err TimerPause(pTimer pt);

extern unsigned long long getSystemTime(void);
extern INT32U getSystemTime32(void);

#define ENTER_CRITICAL()    __set_FAULTMASK(1)

#define EXIT_CRITICAL()     __set_FAULTMASK(0)

#define OS_ENTER_CRITICAL()    __set_FAULTMASK(1)

#define OS_EXIT_CRITICAL()     __set_FAULTMASK(0)

#define MS_PER_TICK  1
#define TIME_ONE_SEC (1000/MS_PER_TICK)

#define TIME_HALF_SEC (500/MS_PER_TICK)

#define TIME_TWO_SEC (TIME_ONE_SEC*2)
#define TIME_THREE_SEC (TIME_ONE_SEC*3)

#define TIME_200_MILL_SEC (200/MS_PER_TICK)

#define TIME_FOUR_SEC (TIME_ONE_SEC*4)
#define TIME_FIVE_SEC (TIME_ONE_SEC*5)
#define OSTimeDly(x) Sys_Delay(x);

#endif /* SYSTICK_H_ */
